﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Graphexcersize
{
    class Program
    {
        static void Main(string[] args)
        {
            
            IBasicGraph graph = new BasicGraph();
            List<Vertex> vertices = new List<Vertex>();
            List<Edge> edges = new List<Edge>();

            Vertex a = new Vertex("A");
            Vertex b = new Vertex("B");
            Vertex c = new Vertex("C");
            Vertex d = new Vertex("D");
            Vertex e = new Vertex("E");
            Vertex f = new Vertex("F");
            Vertex g = new Vertex("G");

            graph.AddVertex(a);
            graph.AddVertex(b);
            graph.AddVertex(c);
            graph.AddVertex(d);
            graph.AddVertex(e);
            graph.AddVertex(f);
            graph.AddVertex(g);

            graph.AddEdge(new Edge(0, a, b, 5));
            graph.AddEdge(new Edge(1, a, c, 4));
            graph.AddEdge(new Edge(2, a, d, 7));
            graph.AddEdge(new Edge(3, b, d, 8));
            graph.AddEdge(new Edge(4, b, e, 4));
            graph.AddEdge(new Edge(5, c, d, 7));
            graph.AddEdge(new Edge(6, c, f, 8));
            graph.AddEdge(new Edge(7, d, e, 6));
            graph.AddEdge(new Edge(8, d, f, 6));
            graph.AddEdge(new Edge(9, d, g, 7));
            graph.AddEdge(new Edge(10, e, g, 5));
            graph.AddEdge(new Edge(11, f, g, 6));

            vertices = graph.VList;
            edges = graph.EList;

            List<Vertex> l = graph.AdjacentVertexes(c);
            List<Vertex> m = graph.AdjacentVertexes(d);

            string sL = "c is adjacent to:";
            foreach(Vertex v in l)
                sL += " "+ v.Name;
            
            string sM = "d is adjacent to:";
            foreach(Vertex v in m)
                sM += " "+ v.Name;
            
            Console.WriteLine(sL);
            Console.WriteLine(sM);

            Dictionary<Vertex, int> temp = graph.ShortestPath(f);

            Console.WriteLine("Afrejsested: " + f.Name);
            foreach (KeyValuePair<Vertex, int> entry in temp)
            {
                Console.WriteLine("Destination: " + entry.Key.Name + "    Afstand: " + entry.Value);
            }

            Console.WriteLine();
            //graph.ShortestPath(a);
            temp.Clear();
            graph.VList = vertices;
            graph.EList = edges;
            Dictionary<Vertex, int>  temp2 = graph.ShortestPath(a);

            Console.WriteLine("Afrejsested: " + a.Name);

            foreach (KeyValuePair<Vertex, int> entry in temp2)
            {
                Console.WriteLine("Destination: " + entry.Key.Name + "    Afstand: " + entry.Value);
            }

            Console.ReadLine();
        }
    }
}
